#!/bin/bash

set -eu
# set -x

export install_path=/usr/local/Ascend/ascend-toolkit/latest
export DDK_PATH=${install_path}
export NPU_HOST_LIB=${install_path}/acllib/lib64/stub
export PATH=/usr/local/python3.7.5/bin:${install_path}/atc/ccec_compiler/bin:${install_path}/atc/bin:$PATH
if [ ! `echo $PYTHONPATH` ];then
    export PYTHONPATH=${install_path}/atc/python/site-packages
else
    export PYTHONPATH=${install_path}/atc/python/site-packages:$PYTHONPATH
fi
export LD_LIBRARY_PATH=${install_path}/atc/lib64:${install_path}/acllib/lib64:$LD_LIBRARY_PATH
export ASCEND_OPP_PATH=${install_path}/opp

root_dir=`dirname $0`
root_dir=`realpath $root_dir`
msquick_dir=${root_dir}/tools/msquickcmp
onnx_model=`realpath $1`
om_model=`realpath $2`
output_dir=$3
mkdir -p $output_dir
output_dir=`realpath $output_dir`

pushd $msquick_dir
if [ $# == 4 ];
then
    input_file=$4
    python3.7 main.py -m $onnx_model -om $om_model -i $input_file -c $install_path -o $output_dir
else
    python3.7 main.py -m $onnx_model -om $om_model -c $install_path -o $output_dir
fi
popd
